package com.stark.commons.spring.core.support.sql;

import org.springframework.beans.BeanUtils;

import com.alibaba.druid.pool.DruidDataSource;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@Data
@EqualsAndHashCode(callSuper=false)
@NoArgsConstructor
public class DruidRoutingDataSource extends DruidDataSource implements RoutingDataSource {

	private static final long serialVersionUID = 8489262358148166202L;
	
	private String lookupKey;
	
	private boolean primary;
	
	public DruidRoutingDataSource(DruidDataSource druidDataSource, String lookupKey, boolean primary) {
		BeanUtils.copyProperties(druidDataSource, this);
		this.lookupKey = lookupKey;
		this.primary = primary;
	}
	
	@Override
	public String getLookupKey() {
		return lookupKey;
	}

	@Override
	public boolean isPrimary() {
		return primary;
	}

}
